package com.wsl.session.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
public class SessionController {
    /**
     * 引用配置文件中的数据需要添加${} 方式引用
     */
    @Value("${server.port}")
    String port;
    @Value("${wsl.common}")
    String common;

    @RequestMapping("set")
    public String set(HttpSession session){
        session.setAttribute("user","wangshuliang");
        return String.valueOf(port)+common;
    }
    @RequestMapping("get")
    public String get(HttpSession session){
        String  user= (String) session.getAttribute("user");
        return user+String.valueOf(port)+common;
    }
}
